Repository navigation
fix(opencode): stop materializing MISTRAL_API_KEY into the server env (vibe-direct must bill the Vibe plan) - #6460
Merged
Conversation
Mistral meters per KEY, not by call metadata. vibe-direct resolves its credential exactly like the vibe binary (env first), so the ExecStartPre materializer exporting the Bitwarden mistral.api-key value (the account API key) silently rerouted all vibe-direct traffic onto the $15 API budget: it burned the pool 16% -> 100% on 2026-11-05 and then walled the mistral-plan route with 402 billing_api_budget_exhausted. With MISTRAL_API_KEY absent from the server env, vibe-direct falls through to the keyring ai.mistral.vibe sign-in key and bills the Vibe plan, as designed (opencode#1653). The mistral provider is unaffected: its enrolled credential (integration mistral) is its source, verified live 2026-11-06. DEEPSEEK_API_KEY materialization is unchanged. Config comments that stated the wrong metering theory are corrected. Refs: developing-today-forks/opencode#1653
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This was referenced Nov 6, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
Mistral meters per key, not by call metadata.
vibe-directresolves its credential exactly like thevibebinary \u2014 envMISTRAL_API_KEYfirst, then~/.vibe/.env, then the OS keyring (ai.mistral.vibe). The home-managerExecStartPrematerializer exported the Bitwardenmistral.api-keyvalue \u2014 the account API key (sha256 fp144cdb68\u2026, the same value as the enrolledmistralintegration credential) \u2014 into the server unit env, so every vibe-direct request spent the API key and billed the $15 API budget. The keyring sign-in key (fpb782943c\u2026) is a different key and is the one that bills the Vibe plan.Proven empirically 2026-11-06: the real
vibeCLI succeeds on the keyring key while the API budget is exhausted; the same CLI forced onto the server env key returns the exact production error402 billing_api_budget_exhausted. Attribution: on 2026-11-05, while vibe-direct carried the deepseek-flash-plan load, 8,693 vibe-direct attempts went to Mistral, 8,660 of them inside the 16%->100% burn window (22:45Z wall) \u2014 yes, our own mis-keyed traffic burned the API pool.Change
home/common/default.nix: the materializer no longer writesMISTRAL_API_KEY(DEEPSEEK_API_KEY unchanged); the comment block now records the verified per-key metering behavior. Script renamedopencode-env-key-materialize..opencode/opencode.jsonc: comments that stated the wrong theory (same-credential legs; call_source as metering key; env key as vibe-direct's credential) corrected.The
mistralprovider is unaffected: its enrolled credential is its source (verified live with the env var absent: the leg returns the API-budget 402, not an auth error).Runtime state / follow-up after this lands + a switch
A runtime bridge is ALREADY live (2026-11-06): user drop-in
~/.config/systemd/user/opencode.service.d/10-vibe-keyring-fix.confswaps ExecStartPre for a scrub script that deletes only theMISTRAL_API_KEY=line from the materialized env file; verified end-to-end (vibe-direct succeeds, mistral-plan route serves via the vibe leg, plan budget is the one in play). After the nextnixos-rebuild switchactivates this PR, remove the drop-in and~/.local/bin/mistral-env-scrub.sh\u2014 left in place they would freeze DEEPSEEK_API_KEY rotation, since the scrub replaces the materializer wholesale.Refs: developing-today-forks/opencode#1653
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.